home *** CD-ROM | disk | FTP | other *** search
/ The Original Shareware 1.1 / The Original Shareware (WeMake CDs)(Volume 1.1)(CDs, Inc)(1993).iso / 16 / wlabel.zip / WLABEL.C < prev    next >
Text File  |  1986-07-12  |  5KB  |  164 lines

  1. /************************************************************************/
  2. /*                                                                               */
  3. /*                          WINDOW LABEL MAKER                                 */
  4. /*                                                                                 */
  5. /*                            VERSION 1.0                                  */
  6. /*                Compiled with Microsoft C ver 3.0                            */
  7. /*                                                                                 */
  8. /*                    Written by Harold D. Maney, Jr.                            */
  9. /*                        Xanatek Software Systems                               */
  10. /*                              June 13, 1986                                      */
  11. /*                                                                                 */
  12. /************************************************************************/
  13.  
  14. #define  LINT_ARGS   1
  15.  
  16. #include <stdio.h>
  17. #include <ctype.h>
  18. #include <string.h>
  19. #include <conio.h>
  20. #include <fcntl.h>
  21. #include <windows.h>
  22. #include <dos.h>
  23. #include <wlabdef.h>
  24. #include <stdlib.h>
  25.  
  26. main(argc,argv)
  27. int argc;
  28. char *argv[];
  29. {
  30.    WINDOW *Lw, *Cw, *Tw;
  31.    FILE *Pr;
  32.    char c, *labelline, *editbuffer, nrlabels[6];
  33.    char prtfile[39];
  34.    int i, j, k, n, output, label, firstpass;
  35.    static int linelist[] = {0, 1, 2, 3, 4};
  36.    static int charswide = 30;
  37.    static int lineshigh = 5;
  38.    static int lpi = 6;
  39.  
  40.    firstpass = TRUE;
  41.    Cw = wopen(0,0,25,80,DHDV+NOZOOM);
  42.    showlogo();
  43.    Lw = wopen(ctr(5,25),ctr(42,80),5,42,DHDV+NOZOOM);
  44.    wlabel(Lw,"[ LABEL OPTIONS ]",CENTER);
  45.    /*            123456789012345678901234567890123456789012  */
  46.    wprintf(Lw,"\n\n     (M)ultiple names (one label each)");
  47.    wprintf(Lw,"\n     (O)ne name (multiple labels)");
  48.    wprintf(Lw,"\n\n       Please select option:  ");
  49.    label = toupper(getch());
  50.    wclear(Lw);
  51.    wlabel(Lw,"[ OUTPUT OPTIONS ]",CENTER);
  52.    /*            123456789012345678901234567890123456789012  */
  53.    wprintf(Lw,"\n\n             (F)ile output");
  54.    wprintf(Lw,"\n             (P)rinter output");
  55.    wprintf(Lw,"\n\n         Please select option:  ");
  56.    output = toupper(getch());
  57.    if (output == 'F') {
  58.       wclear(Lw);
  59.       wprintf(Lw,"\nPlease enter filename:  ");
  60.       wgetline(Lw,prtfile,39);
  61.    }
  62.    else
  63.       strcpy(prtfile,"LPT1");
  64.    wclose(Lw);
  65.    wclear(Cw);
  66.    Lw = wopen(ctr(lineshigh,25),ctr(charswide,80),lineshigh,charswide,DHDV);
  67.    wlabel(Lw,"[ Ctrl-End to Finish ]",CENTER);
  68.    do {          
  69.       wclear(Lw);
  70.       Lw->editbuffer = 0;
  71.       wputatt(Lw,REVERSE,0,0,charswide);
  72.       do {
  73.          editbuffer = wedit(Lw,linelist,lineshigh);
  74.       }
  75.       while (editbuffer < (char *)256);
  76.       if (editbuffer == (char *)0xffff)
  77.          goto cleanup;
  78.       Tw = wopen(19,ctr(40,80),3,40,DHSV+NOZOOM);
  79.       if (label == 'O') {
  80.          wprintf(Tw,"\n How many labels do you need? <12>");
  81.          if (wgetline(Tw,nrlabels,5) == 0xffff) {
  82.             wclose(Tw);
  83.             goto cleanup;
  84.          }
  85.          n = atoi(nrlabels);
  86.          if (n == 0)
  87.             n = 12;
  88.       }
  89.       else
  90.          n = 1;
  91.       if ((output != 'F') && (firstpass || (label == 'O'))) {
  92.          wclear(Tw);
  93.          wprintf(Tw,"\n Prepare printer then press any key...");
  94.          if (getch() == ESC) {
  95.             wclose(Tw);
  96.             goto cleanup;
  97.          }
  98.       }
  99.       wclear(Tw);
  100.       hidecurs();
  101.       wprintf(Tw,"\n           PRINTING...");
  102.       if (!(Pr = fopen(prtfile,"a"))) {
  103.          wprintf(Tw,"\nERROR - Cannot access printer or print file");
  104.          exit(2);
  105.       }
  106.       for (i=0; i<n; i++) {
  107.          labelline = strtok(strdup(editbuffer),"\x1f\0");
  108.          for (j=0,k=0; j<lineshigh; j++) {
  109.             if (strlen(labelline) > 2) {
  110.                fprintf(Pr,"%s\n",labelline);
  111.                k++;
  112.             }
  113.             labelline = strtok(NULL,"\x1f\0");
  114.          }
  115.          while (k++ < lpi)
  116.             fprintf(Pr,"\n");
  117.       }
  118.       fflush(Pr);
  119.       wclear(Tw);
  120.       showcurs(LINE);
  121.       if (label == 'O') {
  122.          wprintf(Tw,"\n         Do it again? <Y>");
  123.          c = toupper(getch());
  124.       }
  125.       wclose(Tw);
  126.       fclose(Pr);
  127.       firstpass = FALSE;
  128.       free(Lw->editbuffer);
  129.    }
  130.    while ((c != 'N') && (c != ESC));
  131.  
  132. cleanup:
  133.    wclose(Lw);
  134.    wclose(Cw);
  135. }
  136.  
  137. showlogo()
  138. {
  139.    int h, w, l, t;
  140.    WINDOW *Lw;
  141.  
  142.    h = 25;
  143.    w = 80;
  144.    l = 0;
  145.    t = 0;
  146.  
  147.    for (t=0; t<9; t++) {
  148.       box(t,l,h,w,SHSV+NOZOOM);
  149.       l += 2;
  150.       h -= 2;
  151.       w -= 4;
  152.    }
  153.    Lw = wopen(10,19,5,42,BHBV+NOZOOM);
  154.  
  155.    /*          123456789012345678901234567890123456789012  */
  156.    wprintf(Lw,"\n                WindowLabel\n");
  157.    wprintf(Lw,"   A Label Maker by Harold D. Maney, Jr.\n\n");
  158.    wprintf(Lw,"         Please press any key...");
  159.    getch();
  160.    wclose(Lw);
  161. }
  162.  
  163.  
  164.